package com.bootdo.system.task;

import java.util.Date;
import java.util.List;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import com.bootdo.system.domain.Order;
import com.bootdo.system.service.OrderService;

/**
 * @author wh
 * @date 2017年10月30日 下午8:56:49 
*  @Description: 扫描处理超时未支付的订单
 */
@Component
public class OrderScanTask {

	Logger logger = Logger.getLogger(OrderScanTask.class);
	
	@Autowired
	OrderService orderService;
	
	@Scheduled(cron="0 0/15 * * * ?")
    public void orderScan(){
		logger.info("DateTime:" + new Date() +" 开始执行订单超时扫描..."); 
        List<Order> list = orderService.getOutTimeOrders();
        for(Order order:list) {
        	orderService.cancelOrder(order.getId());
        }
    }

}
